package com.example.harmonys_api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.harmonys_api.entity.*;
import com.example.harmonys_api.mapper.CityMapper;
import com.example.harmonys_api.service.ICityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 2251300221陈成权
 * @since 2025-09-30
 */
@Service
public class CityServiceImpl extends ServiceImpl<CityMapper, City> implements ICityService {
    @Resource
    CityMapper cityMapper;
    int pageSize=3;
    Page<City>page=new Page<>(1,pageSize);
    public Result citylist(Search search){
        System.out.println("进入CityServiceImpl+++citylist（）");
        QueryWrapper<City> qw = new QueryWrapper<>();
        if (search.getKey()!=null){
            System.out.println("----search.getKey()!=null---"+search.getKey());
            qw.like("city_name",search.getKey());
        }
        page.setCurrent(search.getPageInex());
        Page<City> r=cityMapper.selectPage(page,qw);

        Result<Page>cityResult=new Result<>();
        cityResult.setCode(200);
        cityResult.setMsg("查询成功");
        cityResult.setData(r);
        System.out.println("===="+cityResult.toString());


        return cityResult;
    }
}
